package fr.utt.lo02.CrazyEights.model.cards;

import java.io.Serializable;

/**
 * A class representing a card.
 * @author Jeremy
 *
 */

public class Card implements Comparable<Card>,Serializable {

	private static final long serialVersionUID = 1L;
	
	/**
	 * Suit of the card
	 */
	private CardSuit suit;
	/**
	 * Rank of the card
	 */
	private CardRank rank;
	
	/**
	 * Create the card
	 * @param a suit of the card
	 * @param b rank of the card
	 */
	public Card(CardSuit a, CardRank b) {
		suit = a;
		rank = b;
	}
	
	public CardSuit getSuit(){
		return suit;
	}
	
	public CardRank getRank(){
		return rank;
	}
	
	public String toString(){
		return rank+"("+rank.getPoints()+") "+suit;
	}

	/**
	 * To compare 2 Cards, we simply compare their rank.
	 * Because Card implement the Compare interface
	 * we're allowed to use the compareTo method
	 * @param c the card to compare to
	 * @return <0 if this < c ; 0 if this == c ; >0 if this > c
	 */
	@Override
	public int compareTo(Card c) {
		return rank.compareTo(c.getRank());
	}
}
